<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<!DOCTYPE html>
<html>
<head>
<title>项目流程进度</title>
<jsp:include page="../inc.jsp"></jsp:include>
<c:if test="${fn:contains(sessionInfo.resourceList, '/ywXtlckzbController/editPage')}">
	<script type="text/javascript">
		$.canEdit = true;
	</script>
</c:if>
<c:if test="${fn:contains(sessionInfo.resourceList, '/ywXtlckzbController/delete')}">
	<script type="text/javascript">
		$.canDelete = true;
	</script>
</c:if>
<c:if test="${fn:contains(sessionInfo.resourceList, '/ywXtlckzbController/view')}">
	<script type="text/javascript">
		$.canView = true;
	</script>
</c:if>
<script type="text/javascript">
	var dataGrid;
	var dataGrid2;
	var DDHTBHSTR = null;
	$(function() {
		//移动合同表格
		dataGrid = $('#dataGrid').datagrid({
			url : '${pageContext.request.contextPath}/ywYdhtbController/dataGrid',
			fit : true,
			border : false,
			pagination : false,
			idField : 'ID',
			sortName : 'CREATEDATE',
			sortOrder : 'desc',
			checkOnSelect : false,
			selectOnCheck : false,
			nowrap : false,
			striped : true,
			rownumbers : false,
			singleSelect : true,
			queryParams:{ZTSTR_EQ:'生效'},
			columns : [ [{
				field : 'ID',
				title : '编号',
				width : 150,
				hidden : true
			},
			{
					field : 'XLMUN',
					title : '序列号',
					width : 150,
					hidden : true
			} , 
			 {
				field : 'GCMCSTR',
				title : '工程名称',
				width : 200,
				sortable : true
			} ,{
				field : 'DDHTBHSTR',
				title : '订单合同编号',
				width : 150
			} ] ],
			onLoadSuccess : function() {
				$('#searchForm table').show();
				parent.$.messager.progress('close');
				$(this).datagrid('tooltip');
			},
			onRowContextMenu : function(e, rowIndex, rowData) {
				e.preventDefault();
				$(this).datagrid('unselectAll');
				$(this).datagrid('selectRow', rowIndex);
				$('#menu').menu('show', {
					left : e.pageX,
					top : e.pageY
				});
			},
			onDblClickRow :function(rowIndex,rowData){
			 	DDHTBHSTR =rowData.XMBHSTR;
				dataGrid2.datagrid('load', {'DDHTBHSTR_EQ':rowData.DDHTBHSTR});
			},
			onClickRow :function(rowIndex,rowData){
			 	DDHTBHSTR =rowData.XMBHSTR;
				dataGrid2.datagrid('load', {'DDHTBHSTR_EQ':rowData.DDHTBHSTR});
			}
			
		});
		
		
		dataGrid2 = $('#dataGrid2').datagrid({
			url : '${pageContext.request.contextPath}/ywXtlckzbController/findxmlcjdByGrid',
			fit : true,
			border : false,
			pagination : false,
			idField : 'ID',
			sortName : 'XLMUN',
			sortOrder : 'asc',
			checkOnSelect : false,
			selectOnCheck : false,
			nowrap : false,
			striped : true,
			rownumbers : false,
			singleSelect : true,
			columns : [ [
				{
					field : 'ID',
					title : '流程控制表id',
					width : 150,
					hidden : true
				} ,
				{
					field : 'XLMUN',
					title : '流程序号',
					width : 150,
				} ,
				{
					field : 'LCMCSTR',
					title : '流程名称',
					width : 150,
				} ,
				{
					field : 'SFBTSTR',
					title : '是否可跳过本次流程',
					width : 150,
					formatter : function(value, row, index) {
						return  value==1?'可以':'不可以';
					},
					hidden : true
				} ,
				{
					field : 'WCZTNUM',
					title : '完成状态',
					width : 80,
					align:'center',
					formatter : function(value, row, index) {
						return  value==1?'<img src="${pageContext.request.contextPath}/jslib/jquery-easyui-1.3.3/themes/icons/ok.png"  alt="" />'
							:'<img src="${pageContext.request.contextPath}/jslib/jquery-easyui-1.3.3/themes/icons/no.png" alt="" />';
					}
				} ,
				{
				field : 'action',
				title : '操作',
				width : 100,
				align:'center',
				formatter : function(value, row, index) {
					var str = '';
					if ((value==true && row.WCZTNUM!=1 )||"${sessionInfo.editall}"=="true") {
						var url ="${pageContext.request.contextPath}"+row.res.URLSTR;
						str += $.formatString('<img onclick="addTab(\'{0}\',\'{1}\',\'{2}\');"  title="编辑" src="{3}"/>', 
							url, 
							row.res.NAMESTR, 
							row.res.ICONSTR,
							"${pageContext.request.contextPath}/jslib/jquery-easyui-1.3.3/themes/icons/pencil.png"
						);
					}
					return str;
				}
				}
			] ]
		});
	});
	function viewFun(id) {
		if (id == undefined) {
			var rows = dataGrid.datagrid('getSelections');
			id = rows[0].ID;
		}
		parent.$.modalDialog({
			title : '查看移动合同',
			width : 780,
			height : 500,
			href : '${pageContext.request.contextPath}/ywYdhtbController/viewPage?id=' + id
		});
	}
	function addTab(url,title, iconCls) {
		var parm = {
						url : url,
						title : title,
						iconCls : iconCls
					};
		//调用父类打开方法			
		parent.addTab(parm);
	}
</script>
</head>
<body>
	<div class="easyui-layout" data-options="fit : true,border : false">
		<div data-options="region:'west',border:false,split:true" style="width:360px;">
			<table id="dataGrid"></table>
		</div>
		<div data-options="region:'center',border:false">
			<div class="easyui-layout" data-options="fit : true,border : false">
				<div data-options="region:'center',border:false">
					<table id="dataGrid2"></table>
				</div>
			</div>
		</div>
	</div>
	<!-- 移动合同查看菜单 -->
	<div id="menu" class="easyui-menu" style="width: 120px; display: none;">
		<c:if test="${fn:contains(sessionInfo.resourceList, '/ywYdhtbController/viewPage')}">
			<div onclick="viewFun();" data-options="iconCls:'pencil'">查看</div>
		</c:if>
	</div>
</body>
</html>